
package com.sskj.jd.repository;

import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;

import com.sskj.core.query.annotation.DynamicQuery;
import com.sskj.core.repository.GenericRepository;
import com.sskj.personnel.domain.EmployeeQueryParam;
import com.sskj.personnel.domain.entity.EmployeeEntity;

public interface EmployeeForRepository
		extends GenericRepository<EmployeeEntity, String> {

	@Query("from  EmployeeEntity  x  where x.organization.code like ?1%")
	public List<EmployeeEntity> findByOrgCode(String code);
	
	@Query("from  EmployeeEntity  x  where x.name = ?1")
	public EmployeeEntity findByName(String name);	

	@Query("from  EmployeeEntity  x  where x.username = ?1")
	public EmployeeEntity findByUsername(String username);

	@Query("from  EmployeeEntity  x  where x.name = ?1 and x.phone= ?2")
	public EmployeeEntity findByNameOrTelNum(String name, String telNum);

	@Query("update EmployeeEntity set ddId=?1  where id = ?2")
	public void updateDD_IdById(String ddId, String id);

	@Query("from  EmployeeEntity  x  where x.ddId = ?1")
	public EmployeeEntity findByDD_Id(String dd_id);

	@Query("from  EmployeeEntity  x  where x.ddId = ?1")
	public List<EmployeeEntity> findByPhone(String phone);

	@Query("from  EmployeeEntity  x  where x.resteasy_emp_id = ?1")
	public EmployeeEntity findByResteasy_Emp_Id(String resteasy_emp_id);

	@DynamicQuery
	Page<EmployeeEntity> findEmpPage(EmployeeQueryParam employeeQueryParam,
			Pageable pageable);
}
